﻿namespace WMS6.Services
{
    using System;
    using System.Collections.Generic;
    using System.Data;
    using System.ServiceModel;
    using System.ServiceModel.Activation;
    using WMS6.BLL;
    using WMS6.Common;
    using WMS6.DataEntity;
    using WMS6.QueryEntity;

    [AspNetCompatibilityRequirements(RequirementsMode=AspNetCompatibilityRequirementsMode.Allowed), ServiceBehavior(InstanceContextMode=InstanceContextMode.PerCall)]
    public class BillingService : IBillingService
    {
        public string BillingBackUp(string ExecuteDate)
        {
            string temp = string.Empty;
            try
            {
                temp = new ChargesDetailBLL("10").BillingBackUp(ExecuteDate);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "BillingService异常");
            }
            return temp;
        }

        public string BillingClosingStock(string ExecuteDate, List<string> dataBaseID)
        {
            string temp = string.Empty;
            try
            {
                ChargesDetailBLL chargesDetailbll = new ChargesDetailBLL("10");
                return chargesDetailbll.BillingClosingStock(ExecuteDate, dataBaseID);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "BillingService异常");
            }
            return temp;
        }

        public string BillingOperating(string ExecuteDate, List<string> dataBaseID)
        {
            string temp = string.Empty;
            try
            {
                ChargesDetailBLL chargesDetailbll = new ChargesDetailBLL("10");
                return chargesDetailbll.BillingOperating(ExecuteDate, dataBaseID);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "BillingService异常");
            }
            return temp;
        }

        public string DeleteAccessorialCharges(List<string> AccessorialChargesIDS, PubParasInfo pubParasInfo)
        {
            string lineID = string.Empty;
            try
            {
                lineID = new AccessorialChargesBLL(pubParasInfo).DeleteAccessorialCharges(AccessorialChargesIDS);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "BillingService异常");
            }
            return lineID;
        }

        public string DeleteInvoice(InvoiceInfo invoiceInfo, PubParasInfo pubParasInfo)
        {
            string lineID = string.Empty;
            try
            {
                lineID = new InvoiceBLL(pubParasInfo).DeleteInvoice(invoiceInfo);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "BillingService异常");
            }
            return lineID;
        }

        public string DeleteInvoiceDetail(List<string> invoiceID, List<string> lineID, PubParasInfo pubParasInfo)
        {
            string result = string.Empty;
            try
            {
                result = new InvoiceBLL(pubParasInfo).DeleteInvoiceDetail(invoiceID, lineID);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "BillingService异常");
            }
            return result;
        }

        public string DeleteStatement(List<string> StatementIDS, PubParasInfo pubParasInfo)
        {
            string lineID = string.Empty;
            try
            {
                lineID = new StatementBLL(pubParasInfo).DeleteStatement(StatementIDS);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "BillingService异常");
            }
            return lineID;
        }

        public string DeleteStatementDetail(string StatementID, List<string> IDS, PubParasInfo pubParasInfo)
        {
            string lineID = string.Empty;
            try
            {
                lineID = new StatementDetailBLL(pubParasInfo).DeleteStatementDetail(StatementID, IDS);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "BillingService异常");
            }
            return lineID;
        }

        public string GenerateBillingCredence(List<string> docID, List<string> docType, PubParasInfo pubParasInfo)
        {
            string result = string.Empty;
            try
            {
                result = new BillingOrderBLL(pubParasInfo).GenerateBillingCredence(docID, docType);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "BillingService异常");
            }
            return result;
        }

        public string GenerateDailyInvBillingCredence(string ownerID, List<string> days, PubParasInfo pubParasInfo)
        {
            string result = string.Empty;
            try
            {
                result = new BillingDailyInvBLL(pubParasInfo).GenerateDailyInvBillingCredence(ownerID, days);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "BillingService异常");
            }
            return result;
        }

        public string GenerateStorageChargesBillingCredence(string days, List<string> ownerID, PubParasInfo pubParasInfo)
        {
            string result = string.Empty;
            try
            {
                result = new BillingDailyInvBLL(pubParasInfo).GenerateStorageChargesBillingCredence(days, ownerID);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "BillingService异常");
            }
            return result;
        }

        public AccessorialChargesOrderInfo GetAccessorialChargesByID(string orderID, string accessorialType, PubParasInfo pubParasInfo)
        {
            AccessorialChargesOrderInfo accessorialChargesOrderInfo = new AccessorialChargesOrderInfo();
            try
            {
                accessorialChargesOrderInfo = new AccessorialChargesBLL(pubParasInfo).GetAccessorialChargesByID(orderID, accessorialType);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "BillingService异常");
            }
            return accessorialChargesOrderInfo;
        }

        public DataSet GetAccessorialChargesByQueryList(AccessorialChargesQueryEntity tariffQueryEntity, PubParasInfo pubParasInfo)
        {
            DataSet ds = null;
            try
            {
                ds = new AccessorialChargesBLL(pubParasInfo).GetAccessorialChargesByQueryList(tariffQueryEntity);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "BillingService异常");
            }
            return ds;
        }

        public DataSet GetAllAccessorialCharges(PubParasInfo pubParasInfo)
        {
            AccessorialChargesBLL accessorialChargesBLL = new AccessorialChargesBLL(pubParasInfo);
            return accessorialChargesBLL.GetAllAccessorialCharges();
        }

        public DataSet GetAllInvoice(PubParasInfo pubParasInfo)
        {
            InvoiceBLL InvoiceBLL = new InvoiceBLL(pubParasInfo);
            return InvoiceBLL.GetAllInvoiceInfo();
        }

        public DataSet GetAllStatement(PubParasInfo pubParasInfo)
        {
            StatementBLL StatementBLL = new StatementBLL(pubParasInfo);
            return StatementBLL.GetAllStatementInfo();
        }

        public DataSet GetBillingCredenceByQueryList(BillingCredenceQueryEntity billingCredenceQueryEntity, PubParasInfo pubParasInfo)
        {
            DataSet ds = null;
            try
            {
                ds = new BillingCredenceBLL(pubParasInfo).GetBillingCredenceByQueryList(billingCredenceQueryEntity);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "BillingService异常");
            }
            return ds;
        }

        public DataSet GetBillingCredenceByStatementID(string statementID, PubParasInfo pubParasInfo)
        {
            DataSet ds = null;
            try
            {
                ds = new BillingCredenceBLL(pubParasInfo).GetBillingCredenceByStatementID(statementID);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "BillingService异常");
            }
            return ds;
        }

        public DataSet GetBillingCredenceGroupByQueryList(BillingCredenceQueryEntity billingCredenceQueryEntity, PubParasInfo pubParasInfo)
        {
            DataSet ds = null;
            try
            {
                ds = new BillingCredenceBLL(pubParasInfo).GetBillingCredenceGroupByQueryList(billingCredenceQueryEntity);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "BillingService异常");
            }
            return ds;
        }

        public DataSet GetBillingDailyInvByQueryList(BillingDailyInvQueryEntity billingDailyInvQueryEntity, PubParasInfo pubParasInfo)
        {
            DataSet ds = null;
            try
            {
                ds = new BillingDailyInvBLL(pubParasInfo).GetBillingDailyInvByQueryList(billingDailyInvQueryEntity);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "BillingService异常");
            }
            return ds;
        }

        public DataSet GetBillingOrderByQueryList(BillingOrderQueryEntity billingOrderQueryEntity, PubParasInfo pubParasInfo)
        {
            DataSet ds = null;
            try
            {
                ds = new BillingOrderBLL(pubParasInfo).GetBillingOrderByQueryList(billingOrderQueryEntity);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "BillingService异常");
            }
            return ds;
        }

        public InvoiceInfo GetInvoiceByID(string InvoiceID, PubParasInfo pubParasInfo)
        {
            InvoiceInfo InvoiceInfo = new InvoiceInfo();
            try
            {
                InvoiceInfo = new InvoiceBLL(pubParasInfo).GetInvoiceInfoByID(InvoiceID);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "BillingService异常");
            }
            return InvoiceInfo;
        }

        public DataSet GetInvoiceByQueryList(InvoiceQueryEntity invoiceQueryEntity, PubParasInfo pubParasInfo)
        {
            DataSet ds = null;
            try
            {
                ds = new InvoiceBLL(pubParasInfo).GetInvoiceInfoByQueryEntity(invoiceQueryEntity);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "BillingService异常");
            }
            return ds;
        }

        public InvoiceDetailInfo GetInvoiceDetailInfoByID(string invoiceID, string lineID, PubParasInfo pubParasInfo)
        {
            InvoiceDetailInfo invoiceDetailInfo = new InvoiceDetailInfo();
            try
            {
                invoiceDetailInfo = new InvoiceBLL(pubParasInfo).GetInvoiceDetailInfoByID(invoiceID, lineID);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "BillingService异常");
            }
            return invoiceDetailInfo;
        }

        public StatementInfo GetStatementByID(string orderID, PubParasInfo pubParasInfo)
        {
            StatementInfo StatementInfo = new StatementInfo();
            try
            {
                StatementInfo = new StatementBLL(pubParasInfo).GetStatementInfoByID(orderID);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "BillingService异常");
            }
            return StatementInfo;
        }

        public DataSet GetStatementByQueryList(StatementQueryEntity statementQueryEntity, PubParasInfo pubParasInfo)
        {
            DataSet ds = null;
            try
            {
                ds = new StatementBLL(pubParasInfo).GetStatementInfoByQueryEntity(statementQueryEntity);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "BillingService异常");
            }
            return ds;
        }

        public StatementDetailInfo GetStatementDetailInfoByID(string statementID, string LineID, PubParasInfo pubParasInfo)
        {
            StatementDetailInfo statementDetailInfo = new StatementDetailInfo();
            try
            {
                statementDetailInfo = new StatementDetailBLL(pubParasInfo).GetStatementDetailInfoByID(statementID, LineID);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "BillingService异常");
            }
            return statementDetailInfo;
        }

        public string InsertAccessorialCharges(AccessorialChargesInfo accessorialInfo, PubParasInfo pubParasInfo)
        {
            string lineID = string.Empty;
            try
            {
                lineID = new AccessorialChargesBLL(pubParasInfo).InsertAccessorialCharges(accessorialInfo);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "BillingService异常");
            }
            return lineID;
        }

        public string InsertInvoice(InvoiceInfo invoiceInfo, PubParasInfo pubParasInfo)
        {
            string invoiceID = string.Empty;
            try
            {
                invoiceID = new InvoiceBLL(pubParasInfo).InsertInvoice(invoiceInfo);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "BillingService异常");
            }
            return invoiceID;
        }

        public string InsertInvoiceDetail(InvoiceDetailInfo invoiceDetailInfo, PubParasInfo pubParasInfo)
        {
            string result = string.Empty;
            try
            {
                result = new InvoiceBLL(pubParasInfo).InsertInvoiceDetail(invoiceDetailInfo);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "BillingService异常");
            }
            return result;
        }

        public string InsertInvoicePaymentDetail(List<InvoicePaymentDetailInfo> invoicePaymentDetailListInfo, PubParasInfo pubParasInfo)
        {
            string result = string.Empty;
            try
            {
                result = new InvoiceBLL(pubParasInfo).InsertInvoicePaymentDetail(invoicePaymentDetailListInfo);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "BillingService异常");
            }
            return result;
        }

        public string InsertStatement(StatementInfo statementInfo, PubParasInfo pubParasInfo)
        {
            string lineID = string.Empty;
            try
            {
                lineID = new StatementBLL(pubParasInfo).InsertStatement(statementInfo);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "BillingService异常");
            }
            return lineID;
        }

        public string UpdateAccessorialCharges(AccessorialChargesInfo accessorialChargesInfo, PubParasInfo pubParasInfo)
        {
            string lineID = string.Empty;
            try
            {
                lineID = new AccessorialChargesBLL(pubParasInfo).UpdateAccessorialCharges(accessorialChargesInfo);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "BillingService异常");
            }
            return lineID;
        }

        public string UpdateBillingCredencePrintDate(List<BillingCredenceInfo> billingCredenceInfos, PubParasInfo pubParasInfo)
        {
            string result = string.Empty;
            try
            {
                result = new BillingCredenceBLL(pubParasInfo).UpdateBillingCredencePrintDate(billingCredenceInfos);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "BillingService异常");
            }
            return result;
        }

        public string UpdateInvoice(InvoiceInfo invoiceInfo, PubParasInfo pubParasInfo)
        {
            string invoiceID = string.Empty;
            try
            {
                invoiceID = new InvoiceBLL(pubParasInfo).UpdateInvoice(invoiceInfo);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "BillingService异常");
            }
            return invoiceID;
        }

        public string UpdateInvoiceSubmit(List<InvoiceInfo> invoiceListInfo, PubParasInfo pubParasInfo)
        {
            string invoiceID = string.Empty;
            try
            {
                invoiceID = new InvoiceBLL(pubParasInfo).UpdateInvoiceSubmit(invoiceListInfo);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "BillingService异常");
            }
            return invoiceID;
        }

        public string UpdateStatement(StatementInfo statementInfo, PubParasInfo pubParasInfo)
        {
            string lineID = string.Empty;
            try
            {
                lineID = new StatementBLL(pubParasInfo).UpdateStatement(statementInfo);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "BillingService异常");
            }
            return lineID;
        }

        public string UpdateStatementDetailReceived(StatementDetailInfo statementDetailInfo, PubParasInfo pubParasInfo)
        {
            string lineID = string.Empty;
            try
            {
                lineID = new StatementDetailBLL(pubParasInfo).UpdateStatementDetailReceived(statementDetailInfo);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "BillingService异常");
            }
            return lineID;
        }

        public string UpdateStatementStatus(StatementInfo statementInfo, PubParasInfo pubParasInfo)
        {
            string statementID = string.Empty;
            try
            {
                statementID = new StatementBLL(pubParasInfo).UpdateStatementStatus(statementInfo);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "BillingService异常");
            }
            return statementID;
        }
    }
}

